// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

const int N = 1e3+50;

int d1[N][N], d2[N][N];
int f1[N][N], f2[N][N];


template<typename T>
struct E {
    int to;
    T cost;
    E(int to=0, T cost=0):to(to), cost(cost){}
};

template<typename T>
struct Spfa {
    int n;

    static const T INF = 0x3f3f3f3f;
    vector<vector<E<T>>> G;
    void init(int n) {
        this->n = n;
        G.resize(n+1);
        for (int i=0; i<=n; ++i)
            G[i].clear();
    }

    void addEdge(int u, int v, T cost) {
        // dbg(u, v, cost, n);
        assert(u <= n && v <= n);
        G[u].push_back(E<T>(v, cost));
    }

    void go(int s, T d[], int f[]) {
        fill(d, d+n+1, INF);
        d[s] = 0;
        queue<int> q;
        q.push(s);

        static bool in[N];
        memset(in, 0, sizeof(bool) * (n+1));
        in[s] = 1;
        f[s] = -1;
            
        while (!q.empty()) {
            auto u = q.front();
            q.pop();
            in[u] = false;
            // dbg(u, d[u]);
            for (const auto &e : G[u]) {
                int v = e.to; T w = e.cost;
                if (d[u] + w < d[v]) {
                    d[v] = d[u] + w;
                    f[v] = u;
                    if (!in[v]) {
                        in[v] = 1;
                        q.push(v);
                    }
                }
            }
        }
    }

    vector<int> findPath(int s, int t, T d[], int f[]) {
        vector<int> res;
        res.reserve(n);
        for (int v=t; v!=s; v=f[v]) {
            res.push_back(v);
        }
        res.push_back(s);
        reverse(res.begin(), res.end());
        return res;
    }
};

Spfa<int> g1, g2;
int n, m, k;

int main(int argc, char const *argv[]) {
    // code
    int t;
    scanf("%d", &t);
    for (int kk=0; kk<t; ++kk) {
        scanf("%d%d%d", &n, &m, &k);
        g1.init(n);
        g2.init(n);
        for (int i=0; i<m; ++i) {
            int u, v, w;
            scanf("%d%d%d", &u, &v, &w);
            g1.addEdge(u, v, -w);
        }
        for (int i=0; i<k; ++i) {
            int u, v, w;
            scanf("%d%d%d", &u, &v, &w);
            g2.addEdge(u, v, w);
        }
        for (int i=1; i<=n; ++i) {
            g1.go(i, d1[i], f1[i]);
            g2.go(i, d2[i], f2[i]);
        }

        double ans = 0;
        pair<int, int> ap;
        for (int i=1; i<=n; ++i) {
            for (int j=1; j<=n; ++j) {
                int t1 = d1[i][j], t2 = -d2[j][i];
                if (t2 == -0x3f3f3f3f || t1 == 0x3f3f3f3f || t2 == 0)
                    continue;
                // dbg(i, j, t1, t2);
                if (1.0 * t1 / t2 > ans) {
                    ap = make_pair(i, j);
                    ans = 1.0 * t1 / t2;
                } 
            }
        }
        vector<int> v1 = g1.findPath(ap.first, ap.second, d1[ap.first], f1[ap.first]),
        v2 = g2.findPath(ap.second, ap.first, d2[ap.second], f2[ap.second]);
        // dbg(ap.first, ap.second);

        for (int i=0; i<sz(v2); ++i)
            printf("%d ", v2[i]);
        for (int i=1; i<sz(v1); ++i) {
            printf("%d%c", v1[i], i==sz(v1)-1? '\n':' ');
        }

        printf("%.3lf\n", ans);
    }
    return 0;
}
